package com.tyam.bean;

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
public class NotaItens {
	
	@Id
	@GeneratedValue (strategy = GenerationType.AUTO)
	private int codigoNotaItens;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "codigoNota", insertable = true, updatable = true)
	@Fetch(FetchMode.JOIN)
	@Cascade(CascadeType.SAVE_UPDATE)	
	private Nota nota;
	
	@Column(length=250)
	private String descricao;
	
	@Column(precision=9, scale=2, nullable=false)
	private BigDecimal qtd;
	
	@Column(precision=12, scale=2, nullable=false)
	private BigDecimal valor;
	
	@Column(length=1)
	private String status;
	
	@Column(length=10)
	private String und;
	
	@Column(precision=12, scale=2, nullable=false)
	private BigDecimal valorunitario;
	
	
	
	public NotaItens(){
		
	}



	public int getCodigoNotaItens() {
		return codigoNotaItens;
	}



	public void setCodigoNotaItens(int codigoNotaItens) {
		this.codigoNotaItens = codigoNotaItens;
	}



	public Nota getNota() {
		return nota;
	}



	public void setNota(Nota nota) {
		this.nota = nota;
	}



	public String getDescricao() {
		return descricao;
	}



	public void setDescricao(String descricao) {
		this.descricao = descricao;
	}



	public BigDecimal getQtd() {
		return qtd;
	}



	public void setQtd(BigDecimal qtd) {
		this.qtd = qtd;
	}



	public BigDecimal getValor() {
		return valor;
	}



	public void setValor(BigDecimal valor) {
		this.valor = valor;
	}



	public String getStatus() {
		return status;
	}



	public void setStatus(String status) {
		this.status = status;
	}



	public String getUnd() {
		return und;
	}



	public void setUnd(String und) {
		this.und = und;
	}



	public BigDecimal getValorunitario() {
		return valorunitario;
	}



	public void setValorunitario(BigDecimal valorunitario) {
		this.valorunitario = valorunitario;
	}



	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + codigoNotaItens;
		return result;
	}



	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		NotaItens other = (NotaItens) obj;
		if (codigoNotaItens != other.codigoNotaItens)
			return false;
		return true;
	}
	
}
